import wx

class Example(wx.Frame):
    def __init__(self, parent, title):
        super(Example, self).__init__(parent, title=title)
        self.InitUI()
    def InitUI(self):
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

    def OnCloseWindow(self, e):
        dial = wx.MessageDialog(None, 'Are you sure to quit?', "Question", wx.YES_NO|wx.NO_DEFAULT|wx.ICON_QUESTION)
        ret = dial.ShowModal()
        if ret == wx.ID_YES:
            self.Destroy()
        else:
            e.Veto()

def main():
    app = wx.App()
    frame = Example(None, title='VETO')
    frame.Show()
    app.MainLoop()

if __name__ == '__main__':
    main()
